package com.weigang.producer;

import com.weigang.model.CustomMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.jms.Queue;

@Service
public class JmsProducer {

    @Autowired
    private JmsTemplate jmsTemplate;

    @Autowired
    private Queue queue;

    public void sendMessage(String message) {
        jmsTemplate.convertAndSend(queue, message);
        System.out.println("Sent message: " + message);
    }


    public void sendMessage(CustomMessage customMessage) {
        jmsTemplate.convertAndSend(queue, customMessage);
        System.out.println("Sent message----> id：" + customMessage.getId() + ",content：" + customMessage.getContent());
    }
}
